package com.matrix.im.infrastructure.messaging;

import com.matrix.common.constant.RocketMQConstants;
import com.matrix.im.domain.model.ChatMessage;
import com.matrix.im.domain.model.SystemMessage;
import lombok.RequiredArgsConstructor;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.stereotype.Component;

/**
 * @author 有点甜
 * @since 2025/8/2
 */
@Component
@RequiredArgsConstructor
public class MessageBus {

    private final RocketMQTemplate rocketMQTemplate;

    public void publishPrivateMessage(ChatMessage message) {
        rocketMQTemplate.convertAndSend(RocketMQConstants.IM_PRIVATE_MESSAGE_TOPIC, message);
    }

    public void publishSystemMessage(SystemMessage message) {
        rocketMQTemplate.convertAndSend(RocketMQConstants.IM_SYSTEM_MESSAGE_TOPIC, message);
    }
}
